home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CModifierKeyPane.cp < prev    next >
Text File  |  1994-04-04  |  4KB  |  125 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CModifierKeyPane
  3. //|
  4. //| This implements a pane which displays a keyboard shortcut, with modifier
  5. //|__________________________________________________________________________
  6.  
  7. #include "CModifierKeyPane.h"
  8.  
  9.  
  10.  
  11. //========================== Prototypes ===========================\\
  12.  
  13. void DrawModifiers(short modifiers, short h, short v);
  14.  
  15.  
  16. //============================ external globals =======================\\
  17.  
  18. extern CBureaucrat *gGopher;
  19.  
  20.  
  21.  
  22. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. //| CModifierKeyPane::IModifierKeyPane
  24. //|
  25. //| Purpose: Initialize the key pane.
  26. //|
  27. //| Parameters: same as superclass
  28. //|_________________________________________________________
  29.  
  30. void CModifierKeyPane::IModifierKeyPane(CView *anEnclosure, CBureaucrat *aSupervisor,
  31.                         short aHEncl, short aVEncl,
  32.                         SizingOption aHSizing, SizingOption aVSizing, short line)
  33. {
  34.  
  35. #define MODIFIERS_WIDTH    60
  36.  
  37.     IKeyPane(anEnclosure, aSupervisor,                //  Call superclass' initialization routine
  38.                 aHEncl, aVEncl,
  39.                     aHSizing, aVSizing, line);
  40.     
  41.     Rect delta_rect = {0, 0, 0, MODIFIERS_WIDTH};
  42.     ChangeSize(&delta_rect, FALSE);                    //  Make pane big enough for modifiers
  43.     SetAlignCmd(cmdAlignLeft);                        //  Align text left
  44.  
  45.     (**macTE).destRect.left += MODIFIERS_WIDTH;        //  Make room for the modifiers to left of key
  46.  
  47. }    //==== CModifierKeyPane::IModifierKeyPane() ====\\
  48.  
  49.  
  50.  
  51. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. //| CModifierKeyPane::Draw
  53. //|
  54. //| Purpose: This procedure draws the key and the modifiers.
  55. //|
  56. //| Parameters: area: part of the pane to draw
  57. //|______________________________________________________________________
  58.  
  59. void CModifierKeyPane::Draw(Rect *area)
  60. {
  61.  
  62.     CEditText::Draw(area);                        //  Draw the key
  63.     
  64.     DrawModifiers(modifiers, MODIFIERS_WIDTH,
  65.                         frame.top + 3);            //  Draw the modifiers
  66.     
  67.     if (this == gGopher)                        //  Highlight if this is active
  68.         Highlight();
  69.     
  70. }    //==== CModifierKeyPane::Draw() ====\\
  71.     
  72.  
  73. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. //| CKeyPane::DoKeyDown
  75. //|
  76. //| Purpose: This procedure handles a key down event.
  77. //|
  78. //| Parameters: the_char: character associated with key
  79. //|             key_code: the key code of the key
  80. //|             event:    the keydown event
  81. //|______________________________________________________________________
  82.  
  83. void    CModifierKeyPane::DoKeyDown(char the_char, Byte key_code, EventRecord *event)
  84. {
  85.  
  86.     modifiers = event->modifiers;                        //  Remember the modifiers
  87.  
  88.     inherited::DoKeyDown(the_char, key_code, event);    //  Call superclass
  89.  
  90. }    //==== CModifierKeyPane::DoKeyDown() ====\\
  91.  
  92.  
  93.  
  94. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. //| CKeyPane::GetModifiers
  96. //|
  97. //| Purpose: Get the current value of the keyboard shortcut modifiers
  98. //|
  99. //| Parameters: returns the modifiers of the current shortcut
  100. //|_______________________________________________________________________
  101.  
  102. short CModifierKeyPane::GetModifiers(void)
  103. {
  104.  
  105.     return modifiers;
  106.  
  107. }    //==== CModifierKeyPane::GetModifiers() ====\\
  108.  
  109.  
  110.  
  111. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. //| CModifierKeyPane::SetModifiers
  113. //|
  114. //| Purpose: Set the keyboard shortcut to a new value
  115. //|
  116. //| Parameters: modifiers: the new shortcut
  117. //|_______________________________________________________________________
  118.  
  119. void CModifierKeyPane::SetModifiers(short new_modifiers)
  120. {
  121.  
  122.     modifiers = new_modifiers;
  123.     
  124. }    //==== CKeyPane::SetKey() ====\\
  125.